package com.kbatis.sqlsource;

import com.kbatis.sqlsource.iface.SqlSource;
import com.kbatis.utils.GenericTokenParser;
import com.kbatis.utils.ParameterMappingTokenHandler;

/**
 * @ClassName SqlSourceParser
 * @Description
 * @Author 小黄
 * @Date 2019/11/16 15:15
 * @Version 1.0
 */
public class SqlSourceParser {
    public SqlSource parse(String sql) {
        ParameterMappingTokenHandler tokenHandler = new ParameterMappingTokenHandler();
        GenericTokenParser tokenParser = new GenericTokenParser("#{","}",tokenHandler);
        String parse = tokenParser.parse(sql);
        return new StaticSqlSource(parse,tokenHandler.getParameterMappings());
    }
}
